import instance from "@/request/request";

// 登录请求
export const login = (formData)=> instance.post("/user/login",formData)


// 获取验证码请求  返回promise对象
export const getCode =  ()=> instance.get("/captcha")



// 批量删除客户信息
export const batchDeleteClientApi = (ids) => instance.delete("/customer/batchDelete", {data: ids})

// 更新客户状态
export const updateClientAvailableApi = (availableInfo) => instance.put("/customer/updateAvailable", availableInfo)

// 根据客户id 获取客户信息
export const getClientInfoByIdApi = (id) => instance.get("/customer/getById?id=" + id)

// 编辑和添加客户信息
export const addOrUpdateClient = (customer) => instance.post("/customer/addOrUpdate", customer)

// 获取客户信息列表请求
export const getClientPageApi = (pageData) => instance.get("/customer/page", {params: pageData})



// 批量删除供应商信息
export const batchDeleteSupplierApi = (ids) => instance.delete("/provider/batchDelete", {data: ids})

// 更新供应商状态
export const updateSupplierAvailableApi = (availableInfo) => instance.put("/provider/updateAvailable", availableInfo)

// 根据供应商id 获取供应商信息
export const getSupplierInfoByIdApi = (id) => instance.get("/provider/getById?id=" + id)

// 编辑和添加供应商信息
export const addOrUpdateSupplier = (provider) => instance.post("/provider/addOrUpdate", provider)

// 获取供应商信息列表请求
export const getSupplierPageApi = (pageData) => instance.get("/provider/page", {params: pageData})



// 批量删除商品信息
export const batchDeleteCommodityApi = (ids) => instance.delete("/goods/batchDelete", {data: ids})

// 更新商品状态
export const updateCommodityAvailableApi = (availableInfo) => instance.put("/goods/updateAvailable", availableInfo)

// 根据商品id 获取商品信息
export const getCommodityInfoByIdApi = (id) => instance.get("/goods/getById?id=" + id)

// 编辑和添加商品信息
export const addOrUpdateCommodity = (goods) => instance.post("/goods/addOrUpdate", goods)

// 获取商品信息列表请求
export const getCommodityPageApi = (pageData) => instance.get("/goods/page", {params: pageData})

// 获取供应商列表
export const getProviderListApi = () => instance.get("/provider/list")







// 获取角色列表请求
export const getRoleList =  (searchForm)=> instance.get("/role/list",{params:searchForm})

// 改变角色状态
export const updateRoleState =  (stateInfo)=> instance.put("/role/state",stateInfo)

// 添加、编辑角色信息
export const addOrUpdateRole =  (roleForm)=> instance.post("/role/addOrUpdateRole",roleForm)

// 根据id回显信息
export const getRoleById =  (id)=> instance.get("/role/getRoleById?id="+id)

// 根据id删除角色
export const deleteRoleById =  (id)=> instance.get("/role/deleteRoleById?id="+id)

// 获取权限列表
export const getAuthTree = ()=> instance.get('/permission/tree')

// 根据角色id 回显权限
export const getRolePermissionById = (rid)=> instance.get('/permission/getRolePermissionById?id='+rid)

// 添加角色权限
export const addRolePermission = (rolePermission)=> instance.post('/role/addRolePermission',rolePermission)


// 获取用户当前页信息
export const getCurrentPageUserInfoAPI = (searchForm) => instance.post("/user/getCurrentPageUserInfo", searchForm);

// 获取当前用户回显数据
export const getFullUserInfoAPI = (id) => instance.get('/user/getFullUserInfo?id=' + id)

// 获取部门下拉选数据
export const getDeptsListAPI = () => instance.get('/dept/getDeptsList')

// 获取角色下拉框数据
export const getRoleListAPI = () => instance.get('/role/getRolesList')

// 改变用户状态
export const changeUserAvailableAPI = (user) => instance.put('/user/changeUserAvailable', user)

// 批量删除和单删共用接口
export const batchDeleteUserAPI = (ids) => instance.delete('/user/batchDeleteUser', {data: ids})

// 添加更新使用相同接口
export const addAndUpdateUserAPI = (user) => instance.post('/user/addAndUpdateUser', user)

// 获取当前页部门数据
export const getCurrentPageDeptInfoAPI = (searchForm) => instance.post('/dept/getCurrentPageDeptInfo', searchForm)

// 删除单个部门
export const deleteByIdDeptAPI = (id) => instance.delete('/dept/deleteByIdDept?id=' + id)

// 新增或更新部门共用接口
export const addAndUpdateDeptAPI = (dept) => instance.post('/dept/addAndUpdateDept', dept)

// 获取编辑部门表单回显数据
export const getFullDeptInfoAPI = (id) => instance.get('/dept/getFullDeptInfo?id=' + id)

// 改变部门状态
export const changeAvailableAPI = (dept) => instance.put('/dept/changeAvailable', dept)

// 获取当前页日志信息数据
export const getCurrentPageInfoAPI = (searchFrom) => instance.get('/log/getCurrentPageInfo', {params:searchFrom})

// 批量删除日志
export const batchDeleteIdsAPI = (ids) => instance.delete('/log/batchDeleteIds', {data:ids})
// 搜索查询 根据title搜索菜单
export const getPermissionByTitle = (title)=> instance.get('/permission/getPermissionByTitle?title='+title)

// 根据id回显菜单信息
export const getPermissionById = (id)=> instance.get('/permission/getPermissionById?id='+id)

// 根据id删除菜单
export const deletePermissionById = (id)=> instance.delete('/permission/deletePermissionById?id='+id)


// 添加菜单
export const addPermission = (authForm)=> instance.post('/permission/add',authForm)

// 获取菜单  根据token
export const getMenu = ()=> instance.get('/user/getMenu')